<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ tlist.length }} </strong></span
    >
    <ul class="filters">
      <li v-for="(item, i) in istate" :key="i">
        <a
          :class="{ selected: classFlag === isSel[i] }"
          @click="border(i)"
          href="javascript:;"
          >{{ item }}</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="clear">清除已完成</button>
  </footer>
</template>

<script>
import { mapState } from 'vuex'
export default {
  computed: {
    ...mapState('ToDos', ['istate', 'tlist', 'isSel', 'classFlag'])
  },
  methods: {
    // 传递 索引修改对应的样式
    border(index) {
      this.$store.commit('ToDos/listBorder', index)
    },
    // 清除已完成 （不考虑恢复数据）
    clear() {
      this.$store.commit('ToDos/listClear')
    }
  }
}
</script>
